﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;

public partial class Sections : BasePage
{
	protected override void pageLoad()
	{
		//SecurityCheck();
		if (!IsPostBack)
		{
			Fill();
		}
	}
	
	protected override void Fill()
	{
		DataLayer dal = new DataLayer();
		string message = string.Empty;

		Current current = dal.GetCurrent(PAConfiguration.ConnectionString, out message);
		PALogManager.MessageLog(message);
		DataSet data = dal.GetSections(PAConfiguration.ConnectionString, Teacher.TEACHER_ID, current.SemesterId, out message);
		PALogManager.MessageLog(message);
		DataTable dt= data.Tables[0];
		if (!string.IsNullOrEmpty(Sorting))
		{
			dt.DefaultView.Sort = Sorting;
		}

		rgSections.DataSource = dt;
		rgSections.DataBind();
	}
	protected void gvSections_Sorting(object sender, GridViewSortEventArgs e)
	{
		Sort(e);
	}



	protected void rgSections_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
	{
		Sort(e);
	}

	protected void rgSections_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
	{
		Fill();
	}
	protected void rgSections_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
	{

	

		if( (e.Item.ItemType != Telerik.Web.UI.GridItemType.Item)
			&& (e.Item.ItemType != Telerik.Web.UI.GridItemType.AlternatingItem))
			return;	
		
		//	e.Row.Cells[2].Visible = (Teacher.IS_ADMIN == 1) ;

		DataRow row = ((DataRowView)e.Item.DataItem).Row;

		if ((decimal)row["TEACHER_ID"] == Teacher.TEACHER_ID)
		{
			e.Item.Style.Add("background-color", "#66FF66");
			e.Item.Style.Add("text-decoration", "underline");
			e.Item.Style.Add("font-style", "italic");
			e.Item.Style.Add("font-weight", "bold");
		}
	}
}
